<?php
include('checkLogin.php');
$course_id = $_GET['course_id'];
$sql = "select studentid,name,real_name,position from userinfo natural join takes where course_id='$course_id'";
$query = mysqli_query($cn, $sql);
echo "<th>学号</th><th>姓名</th><th>权限</th>";
while ($line = mysqli_fetch_assoc($query)) {
    $stu_id = $line['studentid'];
    if ($line['real_name'] == '') {
        $display_name = $line['name'];
    } else {
        $display_name = $line['real_name'];
    }
    echo "<tr><td>".$line['studentid']."</td><td>".$display_name."</td>";
    if ($line['position'] == "assistant") {
        echo "<td><div class=\"btn-group\">
  <button type=\"button\" class=\"btn\" onclick=\"removePriority('$stu_id')\" id='ord_".$stu_id."'>普通学生</button>
  <button type=\"button\" class=\"btn btn-success\" onclick=\"addPriority('$stu_id')\" id='assis_".$stu_id."'>管理员 </button>
</div></td>";
    } else {
        echo "<td><div class=\"btn-group\">
  <button type=\"button\" class=\"btn btn-success\" onclick=\"removePriority('$stu_id')\" id='ord_".$stu_id."'>普通学生</button>
  <button type=\"button\" class=\"btn\" onclick=\"addPriority('$stu_id')\" id='assis_".$stu_id."'>管理员 </button>
</div></td>";
    }
}